package com.efesco.crm.crm;

import com.bstek.dorado.common.*;
import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.view.*;
import com.bstek.dorado.view.data.*;
import com.bstek.dorado.view.control.*;

/**
 * pipelineManageViewModel
 */
public class crmManageViewModel extends DefaultViewModel {
  
  protected void doUpdateData(ParameterSet parameters)
      throws Exception {
    Dataset dataset_crm=getDataset("dataset_crm");
	DBStatement dbs = new DBStatement();
	RecordIterator itor=dataset_crm.recordIterator();
	
	itor.setVisibility(Dataset.FILTER_ALL);
	while(itor.hasNext()){
		Record record = itor.nextRecord();
		record.setValue("BUSI_TYPE",parameters.getValue("BusiType"));
		
		if (record.getState() == Record.STATE_MODIFIED) {
			record.setState(Record.STATE_NEW);
			dbs.setSql("update s_crm set is_new=null where CRM_ID="+record.getValue("CRM_ID"));
			dbs.execute(); 
		  }
		if (record.getState() == Record.STATE_DELETED) {
			dbs.setSql("update s_crm set is_new=null where CRM_ID="+record.getValue("CRM_ID"));
			dbs.execute(); 
		  }
	
	}
dbs.close();
com.efesco.common.CommUtil.UpdateData(dataset_crm, "s_crm", "CRM_ID");
   // super.doUpdateData(parameters);
  }

}
